From df569ddb1c12693b96a2abfc518860ff344448b5 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Tue, 26 Jul 2005 15:23:50 +0000 Subject: [PATCH] Fix bug where watch messages doesn't go out. Also change xs_test to more closely represent xenbus behaviour so we can see the bug. Signed-off-by: Rusty Russel Signed-off-by: Christian Limpach --- tools/xenstore/xenstored_core.c | 2 +- tools/xenstore/xs_test.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 386d323d37..3689ea4b56 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -253,7 +253,7 @@ static bool write_message(struct connection *conn) out->used = 0; /* Second write might block if non-zero. */ - if (out->hdr.msg.len) + if (out->hdr.msg.len && !conn->domain) return true; } diff --git a/tools/xenstore/xs_test.c b/tools/xenstore/xs_test.c index b7b1ee01ed..13bbbf2d68 100644 --- a/tools/xenstore/xs_test.c +++ b/tools/xenstore/xs_test.c @@ -85,6 +85,14 @@ static const void *get_input_chunk(const struct ringbuf_head *h, return buf + h->read; } +static int output_avail(struct ringbuf_head *out) +{ + unsigned int avail; + + get_output_chunk(out, out->buf, &avail); + return avail != 0; +} + static void update_output_chunk(struct ringbuf_head *h, uint32_t len) { h->write += len; @@ -104,10 +112,12 @@ static bool read_all_shmem(int fd __attribute__((unused)), void *data, unsigned int len) { unsigned int avail; + int was_full; if (!check_buffer(in)) barf("Corrupt buffer"); + was_full = !output_avail(in); while (len) { const void *src = get_input_chunk(in, in->buf, &avail); if (avail > len) @@ -119,7 +129,8 @@ static bool read_all_shmem(int fd __attribute__((unused)), } /* Tell other end we read something. */ - kill(daemon_pid, SIGUSR2); + if (was_full) + kill(daemon_pid, SIGUSR2); return true; } -- 2.30.2